/**
 * 
 */
package com.seascape.swms.system.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.seascape.swms.framework.model.Result;
import com.seascape.swms.framework.service.BaseService;
import com.seascape.swms.framework.web.BaseController;
import com.seascape.swms.system.model.User;
import com.seascape.swms.system.service.UserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author Lay
 *
 */
@Api("用户接口")
@RestController
@RequestMapping("/users")
public class UserController extends BaseController<User>{

	@Autowired
	private UserService userService;

	/* (non-Javadoc)
	 * @see com.seascape.swms.framework.util.BaseController#getBaseService()
	 */
	@Override
	protected BaseService<User> getBaseService() {
		return userService;
	}
	
	@ApiOperation("按角色代码查询用户")
	@GetMapping("/queryUsersByRoleId")
	public Result queryUsersByRoleId(Integer roleId) {
		return Result.success(userService.queryUsersByRoleId(roleId));
	}
	
	@ApiOperation("设置角色")
	@PostMapping("/setRoles")
	public Result setRoles(@RequestParam("userId") Integer userId,@RequestParam("roleIds") List<Integer> roleIds) {
		userService.setRoles(userId, roleIds);
		return Result.success();
	}
}
